package com.csw.android.player.view.controller

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import androidx.databinding.DataBindingUtil
import com.csw.android.dev_utils.ex.ViewEx.gone
import com.csw.android.dev_utils.ex.ViewEx.visible
import com.csw.android.player.R
import com.csw.android.player.base.AbsMediaControllerView
import com.csw.android.player.databinding.PlayerMediaControllerBinding

class MediaControllerView(context: Context, attrs: AttributeSet? = null) :
    AbsMediaControllerView(context, attrs) {

    private val dataBinding: PlayerMediaControllerBinding = DataBindingUtil.inflate(
        LayoutInflater.from(context),
        R.layout.player_media_controller,
        null,
        false
    )

    override fun initView() {
        super.initView()
        dataBinding.run {
            addView(root)
            enterFullScreen.setOnClickListener {
                onControllerListener?.enterFullScreen()
            }
        }
    }

    override fun onShowController() {
        super.onShowController()
        dataBinding.layer1.visible()
    }

    override fun onHideController() {
        super.onHideController()
        dataBinding.layer1.gone()
    }

    //    override fun getPlayPreviousView() = dataBinding.playPrevious
    override fun getPlayView() = dataBinding.play
    override fun getPlayView2() = dataBinding.play2

    //    override fun getPlayNextView() = dataBinding.playNext
    override fun getProgressTextView() = dataBinding.progressTextView
    override fun getProgressBar() = dataBinding.progressBar
    override fun getDurationTextView() = dataBinding.durationTextView

}